from flask import Flask
from flask_cors import CORS
from models.model import db
from views.user import user_bp
from apscheduler.schedulers.background import BackgroundScheduler


def create_app(config):
    flask_app = Flask(__name__)
    flask_app.config.from_object(config)
    cors = CORS(flask_app)
    db.init_app(flask_app)
    flask_app.register_blueprint(user_bp)
    apschedul = BackgroundScheduler()
    flask_app.schedul = apschedul
    flask_app.schedul.start()

    return flask_app
